import { PdfJs } from "../interface";

// Return `true` if `a` is the same as `b`
const isSameUrl = (a: PdfJs.FileData, b: PdfJs.FileData): boolean => {
  const typeA = typeof a;
  const typeB = typeof b;

  if (typeA === "string" && typeB === "string" && a === b) {
    return true;
  }
  if (typeA === "object" && typeB === "object") {
    return (
      a.length === b.length && (a as Uint8Array).every((v, i) => v === b[i])
    );
  }
  return false;
};

export default isSameUrl;
